clear
use Vignette.dta

*Table 1: Summary stats
tab age
tab female
tab urban
tab Burmese
tab education

*Table 2: Experimental assignment
tab democracy COVID_good


*Table 3: Ologit
*Baseline 
ologit Y1 i.democracy i.COVID
outreg2 using a.doc, replace label e(r2_p)
 
*With interaction
ologit Y1  i.democracy i.COVID i.democracy#i.COVID
outreg2 using a.doc, append label  e(r2_p)

*With control
global x="female i.age i.edu urban Burmese Satisfaction_before Satisfaction_after HP_before HP_after"
ologit Y1  i.democracy i.COVID $x
outreg2 using a.doc, append label  e(r2_p)

*With control and ineraction
ologit Y1  i.democracy i.COVID $x i.democracy#i.COVID
outreg2 using a.doc, append label  e(r2_p)

*Marginal effects (without interaction)
ologit Y1  i.democracy i.COVID $x
margins, dydx(democracy)
margins, dydx(COVID)

*Figure 1: Marginal effects (with interaction)
ologit Y1  i.democracy i.COVID $x
margins, dydx(democracy) at(COVID=(0 1)) predict(outcome(5))   post
estimates store X
coefplot X, coeflabels(1._at="COVID situation is bad" 2._at="COVID situation is good") graphregion(color(white)) 



*Appendix A1 and A2: Balance test
tab age, gen(X)
tab education, gen(Z)

ttest female, by(democracy)
ttest Burmese, by(democracy)
ttest urban, by(democracy)

ttest Z1, by(democracy)
ttest Z2, by(democracy)
ttest Z3, by(democracy)

ttest X1, by(democracy)
ttest X2, by(democracy)
ttest X3, by(democracy)
ttest X4, by(democracy)


ttest female, by(COVID)
ttest Burmese, by(COVID)
ttest urban, by(COVID)

ttest X1, by(COVID)
ttest X2, by(COVID)
ttest X3, by(COVID)
ttest X4, by(COVID)

ttest Z1, by(COVID)
ttest Z2, by(COVID)
ttest Z3, by(COVID)




*Appendix B: Contingency table
tab Vignette_response Vignette_design, col chi2



*Appendix C1: Regression (OLS)
*Baseline 
reg Y1 i.democracy i.COVID
outreg2 using a.doc, replace label 
 
*With interaction
reg Y1  i.democracy i.COVID i.democracy#i.COVID
outreg2 using a.doc, append label 

*With control
reg Y1  i.democracy i.COVID $x
outreg2 using a.doc, append label 

*With control and ineraction
reg Y1 i.democracy i.COVID $x i.democracy#i.COVID
outreg2 using a.doc, append label  


*Appendix C2 Table (logit)
*Baseline 
logit Y i.democracy i.COVID
outreg2 using a.doc, replace label e(r2_p)
 
*With interaction
logit Y i.democracy i.COVID i.democracy#i.COVID
outreg2 using a.doc, append label e(r2_p)

*With control
logit Y i.democracy i.COVID $x
outreg2 using a.doc, append label e(r2_p)

*With control and ineraction
logit Y  i.democracy i.COVID $x i.democracy#i.COVID
outreg2 using a.doc, append label  e(r2_p)

*Appendix C2 Figure (logit)
logit Y i.democracy##i.COVID
margins, dydx(democracy) at(COVID=(0 1)) post
estimates store A
coefplot A, coeflabels(1._at="COVID situation is bad" 2._at="COVID situation is good") graphregion(color(white)) title(Marginal effect of democracy)


*Appendix C3
ologit Y1  i.democracy i.COVID i.democracy#i.COVID i.female
outreg2 using a.doc, replace
reg Y1  i.democracy i.COVID i.democracy#i.COVID  i.female
outreg2 using a.doc, append
logit Y2  i.democracy i.COVID i.democracy#i.COVID i.female
outreg2 using a.doc, append

*Appendix D1
tabstat Satisfaction_before Satisfaction_after diff_pre_post, stat(n mean median sd min max) col(stats)

*Appendix D2
ologit Y1 i.democracy i.COVID $x i.democracy#i.COVID if above_median==1
outreg2 using a.doc, replace label
margins, dydx(democracy) at(COVID=(0 1)) predict(outcome(5))   post
estimates store X
coefplot X, coeflabels(1._at="COVID situation is bad" 2._at="COVID situation is good") graphregion(color(white)) 

ologit Y1 i.democracy i.COVID $x i.democracy#i.COVID if above_median==0
outreg2 using a.doc, append label
margins, dydx(democracy) at(COVID=(0 1)) predict(outcome(5))   post
estimates store Y
coefplot Y, coeflabels(1._at="COVID situation is bad" 2._at="COVID situation is good") graphregion(color(white)) 

coefplot (X, label(More critical)) (Y, label(Less critical) msymbol(Oh)), coeflabels(1._at="COVID situation is bad" 2._at="COVID situation is good") graphregion(color(white)) 
